<?php if (!defined('THINK_PATH')) exit(); /*a:1:{s:80:"D:\phpstudy_pro\WWW\nmg002\public/../application/admin\view\money\moneylist.html";i:1657873827;}*/ ?>
 <!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><?php echo $setting['webname']; ?>-收费记录</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <link rel="shortcut icon" href="/public/static/favicon.ico"> <link href="/public/static/admin/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="/public/static/admin/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="/public/static/admin/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="/public/static/admin/css/animate.css" rel="stylesheet">
    <link href="/public/static/admin/css/style.css?v=4.1.0" rel="stylesheet">
	<style>
	  .tools a i{
	    color:#19a9d5
	  }
	  .tools a i:hover{
	    text-shadow:0px 0px 5px #19a9d5;
	  }
	</style>

</head>

<body class="gray-bg">
    <div class="row wrapper border-bottom white-bg page-heading">
        <div class="col-sm-4">
            <h2>收费记录</h2>
            <ol class="breadcrumb">
                <li>
                    <a href="<?php echo url('Admins/admin'); ?>">主页</a>
                </li>
                <li>
                    <strong>收费记录</strong>
                </li>
            </ol>
        </div>
    </div>
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5><?php echo $user['name']; ?>的缴费记录</h5>
                        <div class="ibox-tools tools">
                            <a  data-applyid='' id="pay_money" data-userid='' data-teacher='' data-idcard='' data-name='' data-major='' title='缴费'><i class="glyphicon glyphicon-plus" style="color:#19a9d5" data-type=""></i></a>
						</div>
                    </div>
                    <div class="ibox-content">
                        <div class="row">
                            <div class="col-sm-3">
                                <div class="input-group">
                                    <!--<input type="text" placeholder="请输入关键词" class="input-sm form-control"><span class="input-group-btn">-->
                                    <!--<button type="button" class="btn btn-sm btn-primary"> 搜索</button> </span>-->
                                </div>
                            </div>
                        </div>
                        <div class="table-responsive">
                            <table class="table table-striped" id="datas">
                                <thead>
                                    <tr>
                                        <th>缴费NO</th>
                                        <th>学费</th>
                                        <th>住宿费</th>
                                        <th>学杂费</th>
                                        <th>总计</th>
                                        <th>收款人</th>
                                        <th>收款方式</th>
                                        <th>缴费时间</th>
                                        <th>缴费备注</th>
                                        <th>操作</th>
                                    </tr>
                                </thead>
                                <tbody>
                                <?php foreach($money as $val): ?>
                                <tr>
                                    <td><?php echo $val['pay_number']; ?></td>
                                    <td><?php echo money_zero($val['money_xf']); ?>￥</td>
                                    <td><?php echo money_zero($val['money_zsf']); ?>￥</td>
                                    <td><?php echo money_zero($val['money_xzf']); ?>￥</td>
                                    <td style="color:green;font-weight: bold;"><?php echo number_format($val['money_xf'] + $val['money_zsf'] + $val['money_xzf'],2); ?>￥</td>
                                    <td><?php echo $val['payee']; ?></td>
                                    <td><?php echo $val['pay_type']; ?></td>
                                    <td><?php echo date('Y-m-d H:i:s',$val['create_times']); ?></td>
                                    <td><?php echo $val['comment']; ?></td>
                                    <td>
                                        <a title='修改缴费记录' href="<?php echo url('money/update_money'); ?>?id=<?php echo $val['id']; ?>"><i class="fa fa-pencil" style="color:#19a9d5"></i></a>
                                        <a  class="print" data-id="<?php echo $val['id']; ?>" title='打印缴费凭证'><i class="fa fa-print" style="color:#000000"></i></a>
                                        <a class="del" data-id="<?php echo $val['id']; ?>" data-no="<?php echo $val['pay_number']; ?>" style="color:#cb3d45;"><i class="fa fa-trash"></i></a>
                                    </td>
                                </tr>
                                <?php endforeach; ?>
                                </tbody>

                            </table>
                        </div>

                    </div>
                </div>
            </div>

        </div>
    </div>
    <!--弹出层-->
    <style>
        .layer_notice{
            width: 90%;
            margin:10px auto;
            line-height: 30px;
            display: none;
        }
        .layer_notice select{
            height: 35px;
        }
    </style>
    <!--录取通过-->
    <div class="layer_notice" id="check">
        <input type="hidden" id="userid">
        <input type="hidden" id="applyid">
        <div class="row">
            <label class="col-sm-5 col-xs-5" style="text-align: right;font-size:16px;">姓名：</label>
            <div class="col-sm-7 col-sm-7" id="usernames"><?php echo $user['name']; ?></div>
        </div>
        <div class="row">
            <label class="col-sm-5 col-xs-5" style="text-align: right;font-size:16px;">身份证号：</label>
            <div class="col-sm-7 col-sm-7" id="idcard"><?php echo $user['idcard']; ?></div>
        </div>
        <div class="row">
            <label class="col-sm-5 col-xs-5" style="text-align: right;font-size:16px;">年级：</label>
            <div class="col-sm-7 col-sm-7" id="grade"><?php echo $user['grade']; ?></div>
        </div>
        <div class="row">
            <label class="col-sm-5 col-xs-5" style="text-align: right;font-size:16px;">学费：</label>
            <div class="col-sm-7 col-sm-7">
                <input type="number" id="xf" onkeyup="money_sum()"   placeholder="请输入学费" style="height: 25px;width: 50%" value="<?php echo $setting['money_mr_xf']; ?>">￥
            </div>
        </div>
        <div class="row">
            <label class="col-sm-5 col-xs-5" style="text-align: right;font-size:16px;">学杂费：</label>
            <div class="col-sm-7 col-sm-7">
                <input type="number" id="xzf" onkeyup="money_sum()"  placeholder="请输入学杂费" style="height: 25px;width: 50%" value="<?php echo $setting['money_xzf']; ?>">￥
            </div>
        </div>
        <div class="row">
            <label class="col-sm-5 col-xs-5" style="text-align: right;font-size:16px;">住宿费：</label>
            <div class="col-sm-7 col-sm-7">
                <input type="number" id="zsf" onkeyup="money_sum()"  placeholder="请输入住宿费" style="height: 25px;width: 50%" value="<?php echo $setting['money_zsf']; ?>">￥
            </div>
        </div>
        <div class="row">
            <label class="col-sm-5 col-xs-5" style="text-align: right;font-size:16px;">支付方式：</label>
            <div class="col-sm-7 col-sm-7">
                <select name="pay_type" id="pay_type" style="width: 50%;height: 25px;">
                    <option value="微信">微信</option>
                    <option value="支付宝">支付宝</option>
                    <option value="银联">银联</option>
                    <option value="现金">现金</option>
                </select>
            </div>
        </div>
        <div class="row">
            <label class="col-sm-5 col-xs-5" style="text-align: right;font-size:16px;">收款人：</label>
            <div class="col-sm-7 col-sm-7">
                <input type="text" id="payee" placeholder="请输入收款人" style="height: 25px;width: 50%">
            </div>
        </div>
        <div class="row">
            <label class="col-sm-5 col-xs-5" style="text-align: right;font-size:16px;">备注：</label>
            <div class="col-sm-7 col-sm-7">
                <input type="text" id="comment" placeholder="请输入备注" style="height: 25px;width: 50%">
            </div>
        </div>

        <div class="row">
            <label class="col-sm-5 col-xs-5" style="text-align: right;font-size:16px;">总计：</label>
            <div class="col-sm-7 col-sm-7">
                <div  style="font-size:25px;font-weight: bold;color:green"><span id="money_sum"></span>￥</div>
            </div>
        </div>

        <div class="row">
            <div class="col-sm-12" style="text-align: right;">
                <button class="btn closes">取消</button>
                <button class="btn btn-info" id="pay">确认缴费</button>
            </div>
        </div>
    </div>
    <!--收款凭证-->
    <div class="layer_notice" id="print_advice_node" style="width: 600px;height:320px">

    </div>
    <!-- 全局js -->
    <script src="/public/static/admin/js/jquery.min.js?v=2.1.4"></script>
    <script src="/public/static/admin/js/bootstrap.min.js?v=3.3.6"></script>
    <!-- Peity -->
    <script src="/public/static/admin/js/jquery.jqprint-0.3.js"></script>

    <script src="/public/static/admin/layui/layui.js"></script>
    <script>
        layui.use('layer', function(){ //独立版的layer无需执行这一句
            var $ = layui.jquery, layer = layui.layer; //独立版的layer无需执行这一句
            //点击提交
            $(".del").click(function(){
                $_this = $(this);
                top.layer.msg('你确定要删除\"【'+$_this.data('no')+'】\"这个支付记录吗？', {
                    time: 20000, //20s后自动关闭
                    shade: 0.8,
                    btn: ['确定', '取消'],
                    btn1:function(){
                        $.post("<?php echo url('Money/del'); ?>",{id:$_this.data('id')},function(data){
                            top.layer.closeAll();
                            top.layer.msg(data.msg,{time:2000,shade:0.5},function(){
                                window.location.reload();
                            });
                        });
                    }
                });
            });
        });

        //缴费弹窗
        $("#pay_money").on("click",function(){
            var s = $(this);
            //页面层
            layer.open({
                type: 1,
                skin: false, //加上边框
                title: "确认缴费信息-确定缴费",
                area: ['300px', 'AUTO'], //宽高
                content: $("#check")  //调到新增页面
            });
        });

        //确认缴费
        $("#pay").click(function(){
            var s = $(this);
            if($("#payee").val() == ""){
                top.layer.msg("请输入收款人", {time: 2000,shade:0.5}, function () {
                    $("#payee").focus();
                });
                return false;
            }
            $.post("<?php echo url('Money/pay'); ?>", {
                userid:<?php echo $user['id']; ?>,
                comment:$("#comment").val(),
                money_xf:$("#xf").val(),
                money_xzf:$("#xzf").val(),
                money_zsf:$("#zsf").val(),
                pay_type:$("#pay_type").val(),
                payee:$("#payee").val(),
            }, function (data) {
                layer.closeAll();
                top.layer.msg(data.msg, {time: 2000,shade:0.5}, function () {
                    window.location.reload();
                });
            })
        });
        //关闭弹出层
        $(".closes").click(function(){
            layer.closeAll();
        });

        //打印收据
        $("#datas").on("click",'.print',function(){
            var _this = $(this)
            var _time = Date.parse( new Date() ).toString();//获取到毫秒的时间戳，精确到毫秒
            _time = _time.substr(0,10);//精确到秒

            //请求数据，生成图片
            $("#print_advice_node").empty();

            var base64="";
            var img = new Image();
            img.src= "<?php echo url('Money/create_advice'); ?>?id="+_this.data('id')+"&time="+_time;
            img.onload=function(){
                base64 = image2Base64(img);
                $("#print_advice_node").append($("<img src='"+base64+"' width='100%'/>")); //装转为Base64的图片添加到窗口中
            }
            //页面层
            layer.open({
                type: 1,
                skin: false, //加上边框
                title: "收款凭证",
                area: ['600px', 'AUTO'], //宽高
                content: $("#print_advice_node"),  //
                btn:['打印',"取消"],
                yes:function(){
                    $("#print_advice_node").jqprint();
                    layer.load(1, {
                        shade: 0.5,
                        time: 3*1000,
                    });
                }
            });
        });
        //把图片转为Base64
        function image2Base64(img) {
            var canvas = document.createElement("canvas");
            canvas.width = img.width;
            canvas.height = img.height;
            var ctx = canvas.getContext("2d");
            ctx.drawImage(img, 0, 0, img.width, img.height);
            var dataURL = canvas.toDataURL("image/png");
            return dataURL;
        }
        function money_sum(){
            var xf = $("#xf").val() == "" ? 0 :  parseFloat($("#xf").val());
            var xzf = $("#xzf").val() == "" ? 0 :  parseFloat($("#xzf").val());
            var zsf = $("#zsf").val() == "" ? 0 :  parseFloat($("#zsf").val());
            var sum = xf+xzf+zsf;
            $("#money_sum").text(sum.toFixed(2));
        }
        money_sum();
    </script>

    
    

</body>

</html>
